<?php
// Show a dropdown form for the manager to choose a swimmer to see their swim performance.
function showSwimmerPerformance() {
	echo "<div class='featured-post'>
            <div class='post-title'>
                <h2>Performance History</h2>
			</div>";
	// Get names or all swimmers and show them in the dropdown form
	$query = "SELECT `userID`, `name` FROM `accounts`";
	$result = mysql_query($query) or die("Error getting swimmers: " . myswl_error());
	
	if(mysql_num_rows($result) > 0) {
		echo "<div class='post-entry'><br/><h3>Choose a swimmer</h3>
		<p>Please choose a swimmer bellow to see thier performance history.</p>
		<form action='#' method='post' onsubmit='getSwimmerPerformance(); return false;'>
					<select id='swimmers'>";	
		while($rows = mysql_fetch_assoc($result)) {
			echo "<option value='" . $rows["userID"] . "'>" . $rows["name"] . "</option>";
		}
		// When manager clicks submit, an ajax function will get
		// the swim performance for the chosen swimmer.
		echo "</select><input type='submit' value='Submit' /></form><div id='displaySwimPerf'></div></div>";
	}
	else {
		echo "<p>Your team has no swimmers.</p>";
	}
	echo "</div>";
}
?>